package com.luguz.common.weather;

import java.util.Iterator;
import java.util.List;

/**
 * @author Guz
 * @create 2022-02--27 13:34
 */
public class WeatherFilter {
    public static WeatherForecast FilterWeather(WeatherForecast weatherForecast){
        List<WeatherInfo> forecast = weatherForecast.getData().getForecast();
        for (int i = 0; i < forecast.size(); i++) {
            String str = forecast.get(i).getFengli();
            String data = forecast.get(i).getDate();
//            String[] high = forecast.get(i).getHigh().split(" ");
//            String[] low = forecast.get(i).getLow().split(" ");
            forecast.get(i).setFengli(str.substring(9, 11));
            forecast.get(i).setWeek(data.substring(data.indexOf("星"), data.length()));
            forecast.get(i).setDate(data.substring(0, data.indexOf("星")));
            forecast.get(i).setIcon(MatchingIcon.matchingByType(forecast.get(i).getType()));
//            System.out.println(forecast.get(i).getHigh());
            forecast.get(i).setHigh(forecast.get(i).getHigh().substring(forecast.get(i).getHigh().indexOf(" "),forecast.get(i).getHigh().indexOf("℃")));
            forecast.get(i).setLow(forecast.get(i).getLow().substring(forecast.get(i).getLow().indexOf(" "),forecast.get(i).getLow().indexOf("℃")));
        }
//        System.out.println(weatherForecast);
        return weatherForecast;
    }
}
